/*package site.jlopen.assets.config.interceptor;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import com.fasterxml.jackson.databind.ObjectMapper;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import site.jlopen.entity.BaseResponse;
import site.jlopen.utils.http.BrowserUtil;

public class UiInterceptor implements HandlerInterceptor {
	private static Logger logger = LoggerFactory.getLogger(UiInterceptor.class);

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		logger.info("{}", request.getRequestURI());
		logger.info("{}", request.getRequestURL());
		if("/login".equals(request.getRequestURI())) {
			return true;
		}
		if("/register".equals(request.getRequestURI())) {
			return true;
		}
		Subject subject = SecurityUtils.getSubject();
		if (subject.isAuthenticated()) {
			return true;
		}
		if (BrowserUtil.isAjax(request)) {
			response.setContentType("application/json");
			try (PrintWriter out = response.getWriter()) {
				BaseResponse<String> res = new BaseResponse<String>(401, "Not Login");
				out.write(new ObjectMapper().writeValueAsString(res));
			} catch (IOException e) {
				e.printStackTrace();
			}
			return false;
		}
		Map<String, String[]> params = request.getParameterMap();
		String pp = "";
		if (null != params) {
			pp = pp + "?";
			for (Map.Entry<String, String[]> entry : params.entrySet()) {
				String key = entry.getKey();
				String[] value = entry.getValue();
				if (null != value && value.length > 0) {
					pp = pp + key + "=" + value[0] + "&";
				}
			}
		}
		response.sendRedirect(request.getContextPath() + "login");
		return false;
	}

}
*/